Online services, including large-scale online services accessible on the Internet, use database systems to durably store data. These database systems are often implemented on commodity computer systems that tend to fail eventually. As such, database replication is often used to increase the availability of the data. Database replication creates a secondary copy of primary data on another computer systems such that if the computer systems storing the primary copy fails, the secondary copy is still available.
A benefit of database replication is that it increases data availability. A drawback is that it requires more computer systems. Further, the computer system storing the secondary copy may be underutilized. For example, all write and reads requests for the data may be served by the primary database system.
It is possible to load balance read requests for the data between the primary database system and the secondary database system. However, the database replication may be eventually consistent. As such, a data value that is stored in the primary database may not exist in the secondary database until sometime later. Thus, even if all write operations are sent to the primary database system, a subsequent read operation that is sent to the secondary database system may read a stale data value from the secondary database. In other words, because of the eventual consistency of the database replication, the primary and secondary database systems together may not provide linearizable read and write operations to clients.
The techniques herein address these and other issues.